#!/bin/bash

rootfs_dir=/home/pbb3/qemu-busybox-test/rootfs-xfce
cross_tool_path=/usr/arm-linux-gnueabihf

Iinclude_dir+=" -I$cross_tool_path/include -I$rootfs_dir/include"

Llibs_dir+=" -L$cross_tool_path/lib -L$rootfs_dir/lib"
Llibs_dir+=" -L$rootfs_dir/lib/glib-2.0"

Llibs+=" -lffi -lgio-2.0 -lglib-2.0 -lgmodule-2.0 -lgobject-2.0 -lgthread-2.0 -lz"

export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
export CC=${CROSS_COMPILE}gcc

export LDFLAGS=${Llibs_dir}
export LIBS=$Llibs

export PKG_CONFIG_PATH=${rootfs_dir}/lib/pkgconfig:${PKG_CONFIG_PATH}

export EPREFIX=$rootfs_dir
export PREFIX=$rootfs_dir

./configure --host=arm-linux-gnueabihf --prefix=$rootfs_dir \
    --enable-osx=no \
    --enable-x11=no \
    --enable-fs-linear-filter=no \
    --enable-mmx=no \
    --enable-sse=no \
    --enable-pvr2d=no \
    --enable-fbdev=yes \
    --enable-vnc=no \
    --enable-mesa=no \
    --enable-drmkms=no \
    --enable-jpeg=no \
    --enable-zlib=no \
    --enable-png=yes \
    --enable-gif=no \
    --enable-tiff=no \
    --enable-pnm=no \
    --enable-mpeg2=no \
    --enable-bmp=no \
    --enable-jpeg2000=no \
    --enable-linotype=no \
    --enable-video4linux=no \
    --with-gfxdrivers=vmware,gl,gles2 \

make -j64
make -j64 install

unset CC
unset CFLAGS
unset LDFLAGS
unset LIBS
unset CPPFLAGS
unset CPP
unset PKG_CONFIG
unset PKG_CONFIG_PATH
unset PKG_CONFIG_LIBDIR
unset GLIB_CFLAGS
unset GLIB_LIBS
